import 'package:boss/ui/widget/quit_app.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:hi_common/hi_common.dart';
import 'package:router/annotation.dart';

import 'model/splash.dart';
import 'widget/splash_item.dart';
import 'widget/splash_pagination_plugin.dart';

@RouterConfig(SplashPage.pageName)
class SplashPage extends StatefulWidget {
  static const pageName = '/splashPage';

  @override
  _SplashPageState createState() => _SplashPageState('闪屏页');
}

class _SplashPageState extends BaseState<SplashPage> {
  final List<Splash> splashs = [
    Splash(image: 'assets/image/splash_01.png', title: '语音录菜', subtitle: '菜单识别 只需三秒'),
    Splash(image: 'assets/image/splash_02.png', title: '丰富报表', subtitle: '随时随地掌握经营数据'),
    Splash(image: 'assets/image/splash_03.png', title: '扫码点餐', subtitle: '无需服务员 提高翻台率'),
    Splash(image: 'assets/image/splash_04.png', title: '会员营销', subtitle: '新客盈门 老客常来'),
  ];

  _SplashPageState(String pageName) : super(pageName);

  @override
  Widget build(BuildContext context) {
    ScreenUtil(width: 750, height: 1334).init(context);

    return QuitApp(
      child: Scaffold(
        body: Swiper(
          loop: false,
          itemCount: splashs.length,
          itemBuilder: (context, index) {
            var current = splashs[index];
            return SplashItem(
              data: current,
              isLast: current == splashs.last,
            );
          },
          pagination: SplashPaginationPlugin(),
        ),
      ),
    );
  }
}
